﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'proc_cm_SaveHtmlPage')
BEGIN
    PRINT 'Dropping Procedure proc_cm_SaveHtmlPage'
    DROP  Procedure  proc_cm_SaveHtmlPage
END
GO

PRINT 'Creating Procedure proc_cm_SaveHtmlPage'
GO

CREATE Procedure [dbo].[proc_cm_SaveHtmlPage]
	@pHtmlPageId uniqueidentifier
	, @pPageUrl varchar(128)
	, @pHtmlTitleTxt nvarchar(128) = null
	, @pMetaKeywordTxt nvarchar(1024) = null
	, @pMetaDescriptionTxt nvarchar(1024) = null
	, @pPageTitleTxt nvarchar(128) = null
	, @pParentHtmlPageId uniqueidentifier = null
	, @pMetaNofollowInd bit
	, @pMetaNoarchiveInd bit
	, @pMetaNoindexInd bit
	, @pUseNavigationPathInd bit
	, @pAliasPageUrl varchar(255) = null
	, @pPageSettings nvarchar(max) = null
	, @pIncludeHeaderImageInd bit
	, @pHeaderImageUrl nvarchar(512) = null
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

	update
		[dbo].[tbl_v2_HtmlPage]
	set
		[page_url] = @pPageUrl
		,[html_title_txt] = @pHtmlTitleTxt
		,[meta_keyword_txt] = @pMetaKeywordTxt
		,[meta_description_txt] = @pMetaDescriptionTxt
		,[page_title_txt] = @pPageTitleTxt
		,[updated_utc_dttm] = GETUTCDATE()
		,[parent_html_page_id] = @pParentHtmlPageId
		,[meta_nofollow_ind] = @pMetaNofollowInd
		,[meta_noarchive_ind] = @pMetaNoarchiveInd
		,[meta_noindex_ind] = @pMetaNoindexInd
		,[use_navigation_path_ind] = @pUseNavigationPathInd
		,[alias_page_url] = @pAliasPageUrl
		,[page_settings] = @pPageSettings
		,[include_header_image_ind] = @pIncludeHeaderImageInd
		,[header_image_url] = @pHeaderImageUrl
	where
		[html_page_id] = @pHtmlPageId
END
GO

GRANT EXEC ON dbo.proc_cm_SaveHtmlPage TO PUBLIC
GO

